
import *   as   types from './constants';
import { reqBanner, reqRecommend } from '../../../api/request';
export const changeBanner = (data) => ({
  type: types.CHANGE_BANNER,
  data
}
)
export const changeRecommend = (data) => ({
  type: types.CHANGE_RECOMMEND,
  data
})

export const changeEnterLoad = (data) => ({
  type: types.CHANGE_ENTER_LOAD,
  data
})
export const getBanner = () => {
  return dispatch => {
    reqBanner()
      .then((data) => {
        dispatch(changeBanner(data.banners));
      })
      .catch(() => {
        console.log("轮播图数据传输错误");
      });
  }
}
export const getRecommend = () => {
  return dispatch => {
    reqRecommend()
      .then((data) => {
        dispatch(changeRecommend(data.result));
        dispatch(changeEnterLoad(false));
      })
      .catch(() => {
        console.log("推荐歌单数据传输错误");
      });
  }
}